package string;

import java.util.Random;
import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        Random r = new Random();
        Scanner sc = new Scanner(System.in);

        StringBuilder rCode = new StringBuilder();
        String s ="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz";

        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(63);
            char c = s.charAt(index);
            rCode.append(c);
        }
        System.out.println("随机验证码："+rCode);
        System.out.println("请输入验证码:");
        String code = sc.next();
        rCode = new StringBuilder(rCode.toString().toLowerCase());
        code=code.toLowerCase();
        if (rCode.toString().equals(code)){
            System.out.println("验证成功！");
        }else {
            System.out.println("验证失败。。。");
        }
    }
}
